package il.technion.cs236369.interfaces;

import il.technion.cs236369.exceptions.NotFoundException;

import java.sql.SQLException;

public interface ICacheEntryDal {
	final static int	MAX_ALLOWED_LENGTH	= 255;

	/**
	 * Stores the entry in to the DB
	 * 
	 * @param entry The entry to store
	 * @return True iff the entry already existed
	 * @throws SQLException
	 */
	boolean store(ICacheEntry entry) throws SQLException;

	/**
	 * Loads the entry from the cache
	 * 
	 * @param url The entry's URL
	 * @return The entry with the given URL
	 * @throws NotFoundException If the entry does not exists in the DB
	 * @throws SQLException
	 */
	ICacheEntry load(String url) throws NotFoundException, SQLException;

	/**
	 * Check if a given entry is stored in the DB
	 * 
	 * @param url The entry's URL
	 * @return True iff the entry exists
	 * @throws SQLException
	 */
	boolean contains(String url) throws SQLException;

	/**
	 * Removes an entry from the DB
	 * 
	 * @param url The entry's URL
	 * @return True iff the entry was removed
	 * @throws SQLException
	 */
	boolean remove(String url) throws SQLException;

	/**
	 * Clears the DB of all data
	 */
	void clear() throws SQLException;
}
